<!DOCTYPE html>
<html lang="en">
<head>
    {include file="public:meta" /}
    <title>登录页面</title>
</head>
<body>
<div class="login_page">
    <img class="logo-login" src="/static/images/logo-login.png" alt="logo">
    <h1>欢迎使用 易腾博客后台</h1>
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-input-inline input-custom-width">
                <input type="text" name="username" lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-inline input-custom-width">
                <input type="password" name="password" lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-inline input-custom-width">
                <button class="layui-btn input-custom-width" lay-submit="" lay-filter="login">立即登陆</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    layui.use('form',function(){
        var form = layui.form,
            jq = layui.jquery;


        //监听提交
        form.on('submit(login)', function(data){
            loading = layer.load(2, {
                shade: [0.2,'#000'] //0.2透明度的白色背景
            });
            var param = data.field;
            console.log('formdate',data);
            jq.post('/admin/login/logining',param,function(data){
                console.log('logining',data);
                if(data.code == 200){
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                        location.href = '/admin/index/index';
                    });
                }else{
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                    jq('.captcha img').attr('src','/captcha?id='+Math.random());
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
